package com.htfyun.fragment.library.child;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.htfyun.fragment.library.TreeFragment;
import com.htfyun.fragment.library.adapter.LibraryRecyclerViewAdapter;
import com.htfyun.fragment.library.adapter.TreeRecyclerViewAdapter;
import com.htfyun.fragment.listener.OnRecyclerViewItemClickListener;

import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
import org.geometerplus.fbreader.Paths;
import org.geometerplus.fbreader.book.Book;
import org.geometerplus.fbreader.book.BookEvent;
import org.geometerplus.fbreader.book.IBookCollection;
import org.geometerplus.fbreader.formats.PluginCollection;
import org.geometerplus.fbreader.library.ExternalViewTree;
import org.geometerplus.fbreader.library.FileFirstLevelTree;
import org.geometerplus.fbreader.library.LibraryTree;
import org.geometerplus.fbreader.library.RecentBooksTree;
import org.geometerplus.fbreader.tree.FBTree;
import org.geometerplus.zlibrary.ui.android.R;

import me.yokeyword.fragmentation.anim.DefaultNoAnimator;
import me.yokeyword.fragmentation.anim.FragmentAnimator;

/**
 * Created by sst on 2017/11/1.
 */

public class LibraryContentFragment extends LibraryBaseFragment {
    private static final String ARG_MENU = "arg_menu";


    private int mPosition;

    public static LibraryContentFragment newInstance(int position) {

        Bundle args = new Bundle();

        args.putInt(ARG_MENU, position);

        LibraryContentFragment fragment = new LibraryContentFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Bundle args = getArguments();
        if (args != null) {
            mPosition = args.getInt(ARG_MENU);
        }
    }
    
    @Override
    protected LibraryTree initRootTree(IBookCollection collection, PluginCollection pluginCollection) {

        if (mPosition == 0) {
            return new RecentBooksTree(collection, pluginCollection);
        }  else {
            return new FileFirstLevelTree(collection, pluginCollection);

        }
    }

}
